# -*- encoding: utf-8 -*- 
from datetime import datetime, timedelta
from openerp import SUPERUSER_ID
from openerp import api, fields, models, _
import openerp.addons.decimal_precision as dp
from openerp.exceptions import UserError
from openerp.tools import float_is_zero, float_compare, DEFAULT_SERVER_DATETIME_FORMAT
class fhcode_tb_base(models.Model):
    _name = 'fhcode.tb_base'
    _description = u'基本表'
    _rec_name='fen'
    _order='create_date DESC'	
    def get_employee(self):
        obj = self.env['hr.employee']
        idsobj = obj.search([('user_id','=',self.env.user.id)])
        print('-------------------------------------')		
        print(self.env.user.id)		
        #print(ids)	
        res = idsobj.read()
        print(res)					
        return res and res[0]['id'] or 0					
    fen= fields.Char(u'英文',readonly=False,required=False,translate=False)
    fname= fields.Char(u'中文',readonly=False,required=False,translate=False)
    ftype=fields.Selection([('char',u'char'),('integer',u'integer'),('float',u'float'),('boolean',u'boolean'),('selection',u'selection'),('date',u'date'),('datetime',u'datetime'),('text',u'text'),('function',u'function'),('many2one',u'many2one'),('many2many',u'many2many'),('one2many',u'one2many')],u'类型',readonly=False,required=False,translate=False)
    required= fields.Boolean(u'必填',)
    readonly= fields.Boolean(u'必读',)
    invisible= fields.Boolean(u'是否显示',)
    note=fields.Text(u'描述',readonly=False,required=False,translate=False,default="select f1 form tb1")
    many2one= fields.Char(u'many2one标题',readonly=False,required=False,translate=False)
    many2many=fields.Char(u'many2man标题',readonly=False,required=False,translate=False)
	
	
    many2oneII= fields.Char(u'many2one对象',readonly=False,required=False,translate=False)
	
    many2oneIII=fields.Text(u'描述',readonly=False,required=False,translate=False,default="{'fhcode':'ok'}")	
	
	
	
	
    many2manyII=fields.Char(u'many2man对象',readonly=False,required=False,translate=False)
	
    one2many= fields.Char(u'one2many对象',readonly=False,required=False,translate=False)
    one2manyII=fields.Char(u'one2many对象',readonly=False,required=False,translate=False)	
	
    many2manytype=fields.Selection([('0',u'下拉框'),('1',u'列表')],u'many2many类型',readonly=False,required=False,translate=False)	
	
	
	
    FDisable=fields.Selection([('0',u'启用'),('1',u'停用')],u'是否停用',readonly=False,required=False,translate=False)
    order_line = fields.One2many('fhcode.tb_baseline', 'pay_id', string='selection', copy=True)
    order_linemany2many =fields.Many2many("fhcode.tb_base", 'order_linemany2many', 'move_id', 'route_id',string='Invoices',) #fields.One2many('fhcode.tb_baselinemany2many', 'pay_id', string='many2many', copy=True)

    order_lineone2many =fields.Many2many("fhcode.tb_base",'order_linemany2many', 'move_id', 'route_id', string='Invoices',) #fields.One2many('fhcode.tb_baselineone2many', 'pay_id', string='many2many', copy=True)	
	
		
    @api.model		
    @api.model		
    def action_funproved0(self):
        #context = context or {}
        t=fields.datetime.now()
        #huid=self.get_employee(cr,uid,context)
        self.write({'Fstatus':'wait_prove','FAdddate':t})       
        return True
		
    @api.model		
    def action_funproved(self):
        #context = context or {}
        t=fields.datetime.now()
        #huid=self.get_employee(cr,uid,context)
        self.write({'Fstatus':'proved','FAdddate':t})       
        return True		
    @api.model		
    def create(self, vals):
        result = super(fhcode_tb_base, self).create(vals)	
        return result
    @api.multi		
    def write(self, values):
	    
        result = super(fhcode_tb_base, self).write(values)		
		
        return result
    @api.multi
    def unlink(self):
	
        return super(fhcode_tb_base, self).unlink()
    @api.multi
    def copy(self, default=None):
        return super(fhcode_tb_base, self).copy(default)
    @api.multi
    def search(self, args, offset=0, limit=None, order=None, context=None, count=False):
        domain =None		
        domain = [('Fstatus', '=', '0')]		
        return super(fhcode_tb_base, self).search(args, offset=offset, limit=limit, order=order, count=count)		
fhcode_tb_base() #对象定义结束
class fhcode_tb_baseline(models.Model):
    _name = 'fhcode.tb_baseline'
    _description = u'详细信息'
    #_rec_name='FClass'
    def get_employee(self, cr, uid, context={}):
        obj = self.pool.get('hr.employee')
        ids = obj.search(cr, uid, [('user_id','=',uid)])
        res = obj.read(cr, uid, ids, ['id','name'], context)
        return res and res[0]['id'] or 0
    pay_id=fields.Many2one('fhcode.tb_base',u'fhcode_tb_base',required=True, ondelete='cascade', index=True, copy=False)
    fkec=fields.Char(u'值',readonly=False,required=False,translate=False)
    fkecsl=fields.Char(u'内容',readonly=False,required=False,translate=False)
    FAddperson =fields.Many2one('hr.employee',u'添加人',readonly=False,required=False,translate=False)
    FConsultant=fields.Many2one('hr.employee',u'班主任',readonly=False,required=False,translate=False)					   
    FAdddate= fields.Datetime(u'添加日期',readonly=False,required=False,translate=False)
    Fstatus=fields.Selection([('0',u'未分班'),('1',u'已分班')],u'是否分班',readonly=False,required=False,translate=False)					   
    FDisable=fields.Selection([('0',u'启用'),('1',u'停用')],u'是否停用',readonly=False,required=False,translate=False) 
	
fhcode_tb_baseline() #对象定义结束


